package com.sdy.kzyy.biz.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdy.kzyy.biz.dto.ManagerDTO;
import com.sdy.kzyy.biz.model.Manager;
import com.sdy.kzyy.biz.mapper.ManagerMapper;
import com.sdy.kzyy.biz.service.ManagerService;
import com.sdy.mvc.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zzq
 * @since 2020-03-25
 */
@Slf4j
@Service
public class ManagerServiceImpl extends BaseServiceImpl<Manager> implements ManagerService {
    @Autowired
    private ManagerMapper managerMapper;

    @Override
    public void updById(Manager manager) {
        lambdaUpdate().eq(Manager::getId,manager.getId())
                .set(Manager::getName,manager.getName())
                .set(Manager::getStoreCode,manager.getStoreCode())
                .update();
    }

    @Override
    public void updStaById(Manager manager) {
        lambdaUpdate().eq(Manager::getId,manager.getId())
                .set(Manager::getState,manager.getState())
                .update();
    }

    @Override
    public void updPwdById(Manager manager) {
        lambdaUpdate().eq(Manager::getId,manager.getId())
                .set(Manager::getPassword,manager.getPassword())
                .update();
    }

    @Override
    public Manager getByPhone(String phone) {
        return lambdaQuery().eq(Manager::getPhone,phone).one();
    }

    @Override
    public List<ManagerDTO> getManagerPage(String phone, String storeCode, Page<ManagerDTO> page) {
        return managerMapper.getManagerPage(phone,storeCode,page);
    }

    @Override
    public Integer getManagerPageSize(String phone, String storeCode) {
        return managerMapper.getManagerPageSize(phone, storeCode);
    }
}
